import store from '@/store'
import Vue from 'vue'
import {theme_config} from './defaultSettings'
import {deviceMode} from '@/utils/deviceMode'

//调用位置在main.js
export function Initializer() {
    //初始化主题，主要是给ant的组件用的，看看本地储存里有没有（前提是有设置主题的功能），否则用默认配置的
    store.commit('SET_SIDEBAR_TYPE', Vue.local.get('SIDEBAR_TYPE', true))
    store.commit('TOGGLE_THEME', Vue.local.get('DEFAULT_THEME', theme_config.navTheme))
    store.commit('TOGGLE_LAYOUT_MODE', Vue.local.get('DEFAULT_LAYOUT_MODE', theme_config.layout))
    store.commit('TOGGLE_FIXED_HEADER', Vue.local.get('DEFAULT_FIXED_HEADER', theme_config.fixedHeader))
    store.commit('TOGGLE_FIXED_SIDERBAR', Vue.local.get('DEFAULT_FIXED_SIDEMENU', theme_config.fixSiderbar))
    store.commit('TOGGLE_CONTENT_WIDTH', Vue.local.get('DEFAULT_CONTENT_WIDTH_TYPE', theme_config.contentWidth))
    store.commit('TOGGLE_FIXED_HEADER_HIDDEN', Vue.local.get('DEFAULT_FIXED_HEADER_HIDDEN', theme_config.autoHideHeader))
    store.commit('TOGGLE_WEAK', Vue.local.get('DEFAULT_COLOR_WEAK', theme_config.colorWeak))
    store.commit('TOGGLE_COLOR', Vue.local.get('DEFAULT_COLOR', theme_config.primaryColor))
    store.commit('SET_MULTI_PAGE', Vue.local.get('DEFAULT_MULTI_PAGE', theme_config.multipage))

    //初始化拿到token
    store.commit('SET_TOKEN', Vue.local.get("ACCESS_TOKEN"))
}

//获得当前设备到底什么，调用位置为APP.vue，监控，但是第一次create是不会有的，所以store那里要先设置为desktop
export function Initializer_deviceMode(){
    deviceMode(function call(type){
        if(type==="desk"){
            store.commit('TOGGLE_DEVICE', 'desktop')
            store.commit('SET_SIDEBAR_TYPE', true)
        }
        else{
            store.commit('TOGGLE_DEVICE', 'mobile')
            store.commit('SET_SIDEBAR_TYPE', false)
        }
    })
}

//局部引入ant组件
import { 
    FormModel,
    Checkbox,
    notification,
    Modal,
    Icon,
    Form,
    Col,
    Input,
    Row,
    Button,
    Steps,
    Card,
    Layout,
    Tabs,
    Dropdown,
    Menu,
    Select,
    message,
    Drawer,
    Table,
    Tag,
    Divider,
    Radio,
    Popconfirm,
    Upload

} from 'ant-design-vue'
Vue.use(FormModel)
Vue.use(Divider)
Vue.use(Checkbox)
Vue.use(Icon)
Vue.use(Popconfirm)
Vue.use(Form)
Vue.use(Col)
Vue.use(Input)
Vue.use(Row)
Vue.use(Steps)
Vue.use(Card)
Vue.use(Button)
Vue.use(Layout)
Vue.use(Tabs)
Vue.use(Dropdown)
Vue.use(Menu)
Vue.use(Tabs)
Vue.use(Select)
Vue.use(Modal)
Vue.use(Drawer)
Vue.use(Tag)
Vue.use(Table)
Vue.use(Radio)
Vue.use(Upload)
Vue.prototype.$notification = notification
Vue.prototype.$Modal = Modal
Vue.prototype.$confirm = Modal.confirm
Vue.prototype.$warning = Modal.warning
Vue.prototype.$message = message